<template>
	<!-- 兑换记录 -->
	<view class="exchange-record">
		<nav-bar :title="i18n.exchange.record" @_back="_back" />
		<view class="container">
			<record-list v-for="item in list" :key="item.id" :obj="item" @click="recordClick" />
		</view>
		<u-empty v-if="isEmpty && !list.length" :text="i18n.common.noHistory" mode="history"></u-empty>
		<custom-loading text="" mask="true" click="true" ref="loading"></custom-loading>
	</view>
</template>

<script>
	import minix from '@/utils/minix.js'
	import RecordList from '@/components/Record/index.vue'
	import {
		walletExchange_log
	} from '@/api/index.js'
	import {
		mapGetters
	} from 'vuex'
	import CustomLoading from '@/components/Loadidng/index.vue'
	export default {
		mixins: [minix],
		components: {
			RecordList,
			CustomLoading
		},
		computed: {
			...mapGetters(['token']),
			i18n() {
				return this.$t('message');
			},
		},
		data() {
			return {
				list: [],
				isEmpty: false
			}
		},
		mounted() {
			this.loadList()
			this.$refs.loading.open();
		},
		methods: {
			_back() {
				uni.navigateBack({
					delta: 2
				})
			},
			recordClick(id) {
				uni.navigateTo({
					url: '/pages/exchange/detail?id=' + id
				})
			},
			async loadList() {
				this.list = [];
				let {
					error,
					res
				} = await walletExchange_log({
					token: this.token
				});
				this.$refs.loading.close();
				if (error) return;
				this.isEmpty = true;
				let data = res.list || [];
				if (!data.length) return;
				for (let i in data) {
					let obj = {
						address: data[i].info,
						create_time: data[i].created_time,
						number: data[i].value,
						status: 3,
						id: data[i].id
					}
					this.list.push(obj);
				}
			}
		}
	}
</script>

<style>
</style>
